﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace QuaManSys.InnerInfo
{
    public partial class InnerMainPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["CurUser"] != null)
            {
                //根据当前用户的身份显示消息提醒栏
                ShowReminder((Tab_Person)Session["CurUser"]);
            }
            else
            {
                //跳转到登录页面
                Response.Redirect("~/Login.aspx");
            }
        }

        private void ShowReminder(Tab_Person user)
        {
            string dept = user.department;
            if ("QA" == dept)
            {
                int inDis = CommonFunctions.QueryInnerStatusDis();
                int inPro = CommonFunctions.QueryInnerStatusPro(dept);
                int totalItem = inDis + inPro;
                if (totalItem != 0)
                {
                    HyperLink innerHref = new HyperLink();
                    pnlReminder.Controls.Add(innerHref);
                    innerHref.Text = "您共有" + totalItem.ToString() +
                        "条内部质量信息需要处理。";
                    innerHref.Text += "其中有" + inDis.ToString() +
                        "条待分发，" + inPro.ToString() + "条待归档";
                    innerHref.NavigateUrl = "InnerInfoReminderBox.aspx";
                    pnlReminder.Controls.Add(new LiteralControl("<br />"));
                }
                else
                {
                    Label myLabel = new Label();
                    myLabel.Text = "当前内部信息已经处理完毕！";
                    pnlReminder.Controls.Add(myLabel);
                    pnlReminder.Controls.Add(new LiteralControl("<br />"));
                }
            }
            else
            {
                int inPro = CommonFunctions.QueryInnerStatusPro(dept);
                int inRep = CommonFunctions.QueryInnerResStatusPro(dept);
                if (inPro != 0)
                {
                    HyperLink innerHref = new HyperLink();
                    pnlReminder.Controls.Add(innerHref);
                    innerHref.Text = "您共有" + inPro.ToString() +
                        "条内部质量信息需要处理。";
                    innerHref.Text += "其中您为责任部门的有" + inRep.ToString() +"条。" ;
                    innerHref.NavigateUrl = "InnerInfoReminderBox.aspx";
                    pnlReminder.Controls.Add(new LiteralControl("<br />"));
                }
                else
                {
                    Label myLabel = new Label();
                    myLabel.Text = "当前内部信息已经处理完毕！";
                    pnlReminder.Controls.Add(myLabel);
                    pnlReminder.Controls.Add(new LiteralControl("<br />"));
                }
            }
        }
    }
}